// var oForm = document.querySelector("form");
// 	//姓名
// 	var regName = /^\D[a-zA-Z]{5,9}$/i;
// 	var flagName = false;
// 	var oText1 = document.getElementById("text1");
// 	var nameSpan = document.getElementById("nameSpan");
// 	oText1.onblur = function() {
// 		if(regName.test(this.value)){
// 			flagName = true;
// 			nameSpan.innerHTML = "用户名格式正确";
// 		}else{
// 			flagName = false;
// 			nameSpan.innerHTML = "请重新输入";
// 		}
// 	}

//姓名
var regName = /^[\u4e00-\u9fa5]{2,5}$/;
var flagName = false;
var oSpan1=document.querySelectorAll(".sapn1");
var oText1 = document.getElementById("oText1");
// var oSpan = document.querySelectorAll("span");
oText1.onblur = function() {
	if (regName.test(this.value)) {
		flagName = true;
		oText1.style.border = "1px solid green";
		oSpan1[0].style.display="none";
	} else {
		flagName = false;
		oSpan1[0].style.display="block";
		

	}
}

//手机号码
var regNum = /^1[358]\d{9}$/;
var flagNum = false;
// var oSpan2=document.getElementsByClassName("span1");
var oText2 = document.getElementById("oText2");
oText2.onblur = function() {
	if (regNum.test(this.value)) {
		flagNum = true;
		// oText2.Style.backgroundColor="red";
		oText2.style.border = "1px solid green"
		oSpan1[1].style.display="none";
	} else {
		flagNum = false;
		oSpan1[1].style.display="block";
		// oText2.style.border="1px solid red";

	}
}

//密码
// var regPsdNum=/\d+/;
// var regPsdChar=/[a-z A-Z]+/;
// var regPsdLetter=/[@#$]+/;	
// var regPsdLength=/^.{8,18}$/;
var regPwd = /^.{8,18}$/;
var flagPwd = false;
// var oSpan3=document.getElementsByClassName("span1")
var oText3 = document.getElementById("oText3");
oText3.onblur = function() {
	if (regPwd.test(this.value)) {
		flagPwd = true;   
		oText3.style.border = "1px solid green";
		oSpan1[2].style.display="none";
	} else {
		flagPwd = false;
		oSpan1[2].style.display="block";
	}

}

//确认密码
var regRepwd;
var flagRepwd = false;
var oText4 = document.getElementById("oText4");
// var oSpan4=document.getElementsByClassName("span1");
oText4.onblur = function() {
	if (oText3.value == oText4.value) {
		flagRepwd = true;
		oText4.style.border = "1px solid green";
		oSpan1[4].style.display="none";
	} else {
		flagRepwd = false;
	oSpan1[4].style.display="block";
		
	}
}

//注册信息插入到数据库中
	$("#_regBtn").click(function() {
		console.log("dinjfdahf")
		console.log(flagName);
		console.log(flagNum);
		console.log(flagPwd);
		console.log(flagRepwd);
		if (flagName && flagNum && flagPwd && flagRepwd) {
			$.ajax({
				url: "../php/register.php",
				type: "post",
				data: "userName=" + $('#oText1').val() + "&userId=" + $('#oText2').val() + "&userPwd=" + $('#otext3'),
				success: function(resText) {
					console.log(resText);
					if (resText == "注册成功") {
						alert("注册成功");
						$(window).attr('location', '../html/login.html');
					}
				}

			})
		}
	})
